package cn.itcast.service.impl;

import cn.itcast.dao.ItemMapper;
import cn.itcast.domain.Item;
import cn.itcast.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private ItemMapper itemMapper;

    @Override
    public List<Item> getItemList() {
      /*  List<Item> list = itemsMapper.findAll();
        return list;*/
        List<Item> itemList = new ArrayList<Item>();
        itemList.add(new Item("imac", 20000, new Date(), "苹果本很贵"));
        itemList.add(new Item("imac1", 20000, new Date(), "苹果本很贵"));
        itemList.add(new Item("imac2", 20000, new Date(), "苹果本很贵"));
        itemList.add(new Item("imac3", 20000, new Date(), "苹果本很贵"));
        itemList.add(new Item("imac4", 20000, new Date(), "卧槽，苹果本很贵啦！"));
        return itemList;
    }

    @Override
    public boolean saveItem() {
        Item item = new Item("imac", 20000, new Date(), "苹果本很贵");
        Item item1 = new Item("imac1", 20000, new Date(), "苹果本很贵");
        Item item2 = new Item("imac2", 20000, new Date(), "苹果本很贵");
        Item item3 = new Item("imac3", 20000, new Date(), "苹果本很贵");
        Item item4 = new Item("imac4", 20000, new Date(), "卧槽，苹果本很贵啦！");
        Integer integer = itemMapper.insertItem(item);
        Integer integer1 = itemMapper.insertItem(item1);
        Integer integer2 = itemMapper.insertItem(item2);
        Integer integer3 = itemMapper.insertItem(item3);
        Integer integer4 = itemMapper.insertItem(item4);
        System.out.println(integer + " " + integer1 + " " + integer2 + " " + integer3 + " " + integer4);

        return true;
    }
}
